import { GameConst } from "../../../../component/gconst/GameConst";
import { BaseProgressBar } from "../../common/BaseProgressBar";
import { ImagesConst } from "../../../resource/ImagesConst";
import { SWFInfo } from "../../../../../com/gengine/resource/info/SWFInfo";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { GuildAnimalType } from "../info/GuildAnimalType";
type int = number;
//class GuildAnimalGrowthBar
    
    export  class GuildAnimalGrowthBar /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._maxGrowth = GameConst.GuildBeastGrowthThree;
            this._bitmapArray = [];
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            var loc1;
            this._growthBar = new BaseProgressBar(ImagesConst.ProgressBarBg);
            this._growthBar.setSize(480, 14);
            this._growthBar.showProgressText = false;
            this._growthBar.setValue(0, this._maxGrowth);
            this.addChild(this._growthBar);
            this._barSprite = new Object /* flash.display.Sprite */();
            this._barSprite.x = 8;
            this._barSprite.y = 3;
            this._barSprite.mouseEnabled = false;
            this._barSprite.mouseChildren = false;
            this.addChild(this._barSprite);
            with ({}) 
            {
            };
            "GuildAnimalGrowthBar.swf".load(
#error('pushwith') {}
            , 
#error('pushwith') {}
            .onLoaded = (arg1: SWFInfo): void
            {
                _growBarMc = arg1.clip;
                _growBarMc.gotoAndStop(Math.floor(_growth / 100));
                _barSprite.addChild(_growBarMc);
                return;
            })
            this._valueTxt = ObjCreate.createTextField("", 0, 0, 480, 20, this, GlobalStyle.textFormat2);
            this._valueTxt.mouseEnabled = false;
            this._valueTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            LoaderHelp.addResCallBack(ResFileConst.guildAnimal, this.onLoaderHandler);
            return;
        }

        /* internal  */onLoaderHandler(): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            ObjCreate.createBitmap(ImagesConst.GuildAnimalGrowthLabel, -60, -2, this);
            ObjCreate.createBitmap(ImagesConst.GuildAnimalLabel0, 130, 20, this);
            ObjCreate.createBitmap(ImagesConst.GuildAnimalLabel1, 287, 20, this);
            ObjCreate.createBitmap(ImagesConst.GuildAnimalLabel2, 432, 20, this);
            loc1 = ObjCreate.createBitmap(ImagesConst.GuildAnimalIcon0, 160, -2, this);
            loc2 = ObjCreate.createBitmap(ImagesConst.GuildAnimalIcon1, 315, -2, this);
            loc3 = ObjCreate.createBitmap(ImagesConst.GuildAnimalIcon2, 460, -2, this);
            this._bitmapArray.push(loc1);
            this._bitmapArray.push(loc2);
            this._bitmapArray.push(loc3);
            this.fliterBitmap(this._type);
            return;
        }

        /* internal  */fliterBitmap(arg1: int): void
        {
            var loc1=null;
            var loc2=0;
            while (loc2 < this._bitmapArray.length) 
            {
                loc1 = this._bitmapArray[loc2] as Object /* flash.display.Bitmap */;
                if (loc2 != arg1) 
                {
                    loc1.filters = [];
                }
                else 
                {
                    loc1.filters = [GuildAnimalGrowthBar.glowFilter];
                }
                ++loc2;
            }
            return;
        }

        public get growth(): int
        {
            return this._growth;
        }

        public set growth(arg1: int)
        {
            this._growth = arg1;
            this._valueTxt.text = arg1 + "/" + this._maxGrowth;
            if (this._growBarMc) 
            {
                this._growBarMc.gotoAndStop(Math.floor(this._growth / 100));
            }
            this._type = GuildAnimalType.getTypeByGrowth(this._growth);
            this.fliterBitmap(this._type);
            return;
        }

        public set toolTipData(arg1: string)
        {
            this._growthBar.toolTipData = arg1;
            return;
        }

        /* internal */ static /* const */glowFilter: Object /* flash.filters.GlowFilter */=new Object /* flash.filters.GlowFilter */(15788607, 1, 4, 4, 10);

        /* internal */ /* var */_growthBar: BaseProgressBar;

        /* internal */ /* var */_barSprite: Object /* flash.display.Sprite */;

        /* internal */ /* var */_growBarMc: Object /* flash.display.MovieClip */;

        /* internal */ /* var */_valueTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_growth: int;

        /* internal */ /* var */_maxGrowth: int;

        /* internal */ /* var */_type: int;

        /* internal */ /* var */_bitmapArray: Array<any>;
    }
